package com.ehome.poct.core.pasre.report;

import com.ehome.poct.base.api.enums.StripTypeEnums;

import java.util.Map;
import java.util.Objects;

/**
 * @auther: kuiba.peng
 * @date: 2022/11/10 16:12
 * @description:
 */
public abstract class AbstractFactory<T> {

    Map<StripTypeEnums, T> strategyMap;

    public AbstractFactory(Map<StripTypeEnums, T> strategyMap) {
        this.strategyMap = strategyMap;
    }

    public T get(StripTypeEnums stripTypeEnums) {
        T t = strategyMap.get(stripTypeEnums);
        if (Objects.nonNull(t)) {
            return t;
        }
        return strategyMap.get(StripTypeEnums.DEFAULT_TYPE);
    }

    public T get(Integer stripType) {
        T t = strategyMap.get(StripTypeEnums.getStripType(stripType));
        if (Objects.nonNull(t)) {
            return t;
        }
        return strategyMap.get(StripTypeEnums.DEFAULT_TYPE);
    }

}
